<template>
  <div>
    <FixedOperation>
      <!-- 内容 -->
      <el-row :gutter="20">
        <!--产品分类-->
        <el-col :span="24" :xs="24">
          <div class="text-right">
            <el-button
              :disabled="formData.createBy !== userStore.userInfo.userName"
              type="primary"
              @click="handleUpdate"
              >编辑</el-button
            >
            <el-button
              :disabled="formData.createBy !== userStore.userInfo.userName"
              plain
              type="primary"
              @click="handleDelete"
              >删除</el-button
            >
            <!-- <el-button icon="Refresh" @click="handleReset(form)"
              >重置</el-button
            > -->
          </div>
        </el-col>
      </el-row>
    </FixedOperation>
    <div class="app-container">
      <el-row :gutter="20">
        <el-col :span="24" class="m-b-6">
          <el-descriptions :column="1" :size="'small'" border>
            <el-descriptions-item label="所属公司" label-class-name="w-1/6">{{
              formData.deptName
            }}</el-descriptions-item>
            <el-descriptions-item label="销售人员">{{
              formData.salesman
            }}</el-descriptions-item>
            <el-descriptions-item label="入学时间">{{
              formData.enrollmentTime
            }}</el-descriptions-item>
            <el-descriptions-item label="预计毕业时间">{{
              formData.predictGraduationTime
            }}</el-descriptions-item>
            <el-descriptions-item label="提升形式">{{
              formData.promoteType
            }}</el-descriptions-item>
            <el-descriptions-item label="学员姓名">{{
              formData.customerName
            }}</el-descriptions-item>
            <el-descriptions-item label="手机号码">{{
              formData.phoneNumber
            }}</el-descriptions-item>
            <el-descriptions-item label="身份证号码">{{
              formData.idNumber
            }}</el-descriptions-item>
            <el-descriptions-item label="满25周岁">
              <dict-drop
                :options="yes_or_no"
                :value="formData.isStandard"
              ></dict-drop
            ></el-descriptions-item>
            <el-descriptions-item label="性别"
              ><dict-drop
                :options="sys_user_sex"
                :value="formData.sex"
              ></dict-drop
            ></el-descriptions-item>
            <el-descriptions-item label="籍贯">{{
              formData.birthplace
            }}</el-descriptions-item>
            <el-descriptions-item label="民族">{{
              formData.nation
            }}</el-descriptions-item>
            <el-descriptions-item label="政治面貌">{{
              formData.politicsStatus
            }}</el-descriptions-item>
            <el-descriptions-item label="报考学校">{{
              formData.school
            }}</el-descriptions-item>
            <el-descriptions-item label="层次">
              <dict-drop
                :options="order_hierarchy"
                :value="formData.level"
              ></dict-drop>
            </el-descriptions-item>
            <el-descriptions-item label="报考专业">{{
              formData.applyingMajor
            }}</el-descriptions-item>
            <el-descriptions-item label="学号">{{
              formData.studentNumber
            }}</el-descriptions-item>
            <el-descriptions-item label="工作单位">{{
              formData.employer
            }}</el-descriptions-item>
            <el-descriptions-item label="身份证地址">{{
              formData.address
            }}</el-descriptions-item>
            <el-descriptions-item label="目前住址">{{
              formData.currentAddress
            }}</el-descriptions-item>
            <el-descriptions-item label="最高学历">{{
              formData.highestEducation
            }}</el-descriptions-item>
            <el-descriptions-item label="学校名称">{{
              formData.schoolName
            }}</el-descriptions-item>
            <el-descriptions-item label="证书">
              <dict-drop
                :options="have_certificate"
                :value="formData.isCcie"
              ></dict-drop
            ></el-descriptions-item>
            <el-descriptions-item label="学制">
              {{ formData.schoolSystem }}</el-descriptions-item
            >
            <el-descriptions-item label="学习形式">
              {{ formData.studyMode }}</el-descriptions-item
            >
            <el-descriptions-item label="毕业时间">
              {{ formData.graduationTime }}</el-descriptions-item
            >
            <el-descriptions-item label="毕业证书编号">
              {{ formData.certificateNo }}</el-descriptions-item
            >
            <el-descriptions-item label="邮箱">
              {{ formData.email }}</el-descriptions-item
            >
            <el-descriptions-item label="学费总额">
              {{ formData.feesTotal }}</el-descriptions-item
            >
            <el-descriptions-item label="毕业情况">
              <dict-drop
                :options="graduation_status"
                :value="formData.graduationState"
              ></dict-drop
            ></el-descriptions-item>
          </el-descriptions>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script setup name="EducationPromotionDetails">
import { useRouter, useRoute } from 'vue-router'
import useCommonStore from '@/store/modules/common'
import useUserStore from '@/store/modules/user'
import {
  getEducationPromotionDetail,
  delEducationPromotion
} from '@/api/customerManage/trainCustomer'
import {
  educational_system, //学制
  graduation_status, //毕业情况
  have_certificate, //有无证书
  order_hierarchy, //层次
  improve_form, //提升形式
  yes_or_no, //是否
  companyOption //所属公司
} from '@/hooks/dict/order'
import useTagsViewStore from '@/store/modules/tagsView'

const userStore = useUserStore()
const router = useRouter()
const route = useRoute()
const commonStore = useCommonStore()
const { proxy, type } = getCurrentInstance()
const companyData = ref([])
commonStore.getCompanyData().then(e => {
  companyData.value = e
})

const { sys_user_sex } = proxy.useDict(
  'sys_user_sex' //性别
)

const props = defineProps({
  knowledgeData: {
    type: Object,
    require: true,
    default: null
  }
})

const data = reactive({
  formData: { fileList: [] },
  dialogParam: {}
})
const { formData, dialogParam } = toRefs(data)

watch(
  () => route.query.educationPromotionId,
  () => {
    if (route.query.educationPromotionId && route.name == type.name) {
      getFormData(route.query.educationPromotionId)
    }
  },
  {
    immediate: true
  }
)
// 初始化
function init() {}
/** 获取产品详情
 * @param {number}  id 表单id
 */
function getFormData(id) {
  return new Promise((resolve, reject) => {
    getEducationPromotionDetail(id).then(async res => {
      let resData = {}
      resData = res.data
      formData.value = { ...formData.value, ...resData }
      resolve(res)
    })
  })
}

function goTo(url, data) {
  router.push({ path: url, query: data })
}
/**修改按钮操作 */
function handleUpdate(row) {
  goTo('/rsgl/other/knowledgeForm', {
    educationPromotionId: formData.value.id
  })
}
/** 删除按钮操作 */
function handleDelete(row) {
  const educationPromotionIds = formData.value.id
  proxy.$modal
    .confirm('是否删除')
    .then(function () {
      return delEducationPromotion(educationPromotionIds)
    })
    .then(() => {
      proxy.$modal.msgSuccess('删除成功')
      handleReturn()
    })
    .catch(() => {})
}
// 返回、关闭页面
function handleReturn() {
  useTagsViewStore().delView(router.currentRoute.value)
  router.go(-1)
  // router.push({ path: url, query: data })
  //   proxy.$refs.form.clearValidate()
}
init()
</script>
<style scoped></style>
